{extend name="layout/iframe" /}

{block name="pagecss"}
<link href="__STATIC__/plugins/layui-formSelects/formSelects-v4.css" rel="stylesheet" type="text/css" />
<style>
    .layui-form-label {
        width: 182px;
    }
    .layui-input-block {
        margin-left: 215px;
    }
    .layui-form-item .layui-inline {
        margin-right: 0;
    }
</style>
{/block}

{block name="content"}
<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-col-md9 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md9 layui-col-xs7">
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label"><span class="required">*</span>是否启用</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="status" {if condition="($info.status == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|禁用" {if condition="($info.id == 1)"}disabled="disabled"{/if}><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="required">*</span>等级名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="name" value="{$info.name}" maxlength="20" lay-verify="name" placeholder="" autocomplete="off">
                        </div>
                    </div>
                </div>
                <!--<div class="layui-col-md3 layui-col-xs5">
                    <div id="upload-image">
                        <div class="layui-upload-list thumbBox mag0 magt3" id="upload-btn" data-multi="false">
                            <input type="hidden" class="layui-input" name="img_url" value="{$info.img_url}">
                            <img class="layui-upload-img thumbImg" src="{$info.img_url}">
                        </div>
                    </div>
                </div>-->
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>是否首单立减</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_first_order" {if condition="($info.is_first_order == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|不启用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>立减金额占首单金额比例(%)</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="first_single_reduction" value="{$info.first_single_reduction}" lay-verify="first_single_reduction" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>是否消费送积分</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_gives_points" {if condition="($info.is_gives_points == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|不启用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>每消费1元送积分</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="integral_quantity" value="{$info.integral_quantity}" maxlength="20" lay-verify="integral_quantity" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>是否充值送现金</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_recharge" {if condition="($info.is_recharge == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|不启用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>选择充值模板</label>
            <div class="layui-input-block">
                <select name="recharge_rule_id" lay-verify="recharge_rule_id">
                    <option value="">请选择</option>
                    {foreach name="rechargeRules" item="rechargeRule"}
                        <option value="{$rechargeRule.id}" {if condition="($rechargeRule.id == $info.recharge_rule_id)"}selected=""{/if}>{$rechargeRule.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>是否生日送积分</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_birthday_integral" {if condition="($info.is_birthday_integral == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|不启用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>会员生日免费送积分</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="birthday_quantity" value="{$info.birthday_quantity}" maxlength="20" lay-verify="birthday_quantity" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>是否送超级券</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_coupon" {if condition="($info.is_coupon == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|不启用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>选择超级券</label>
            <div class="layui-input-block">
                <select name="coupon_ids" id="coupons" xm-select="coupons" lay-verify="coupon_ids">
                    {foreach name="coupons" item="coupon" key="couponKey"}
                        <option value="{$coupon.id}" {if condition="(in_array($coupon.id, $info.coupon_ids))"}selected=""{/if}>{$coupon.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>开通会员</label>
            <div class="layui-input-block">
                {if condition="($info.id == 1)"}
                    <input type="checkbox" name="is_payment" lay-filter="is_payment" lay-skin="switch" lay-text="付费|免费" disabled><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>付费</em><i></i></div>
                {else /}
                    <input type="checkbox" name="is_payment" {if condition="($info.is_payment == 1)"}checked=""{/if} lay-filter="is_payment" lay-skin="switch" lay-text="付费|免费"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>付费</em><i></i></div>
                {/if}
            </div>
        </div>
        <div class="payment-rule" {if condition="($info.is_payment == 2)"}style="display: none;"{/if}>
            <div class="payment-rule-group">
                {foreach name="info.payment_rules" item="rule" key="rulekey"}
                    <div class="layui-form-item layui-form-text rule-group">
                        <div class="layui-inline">
                            <label class="layui-form-label"><span class="required">*</span>费用</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input vip_cost" name="vip_cost[{$rulekey}]" value="{$rule.vip_cost / 100}" maxlength="10" placeholder="元" autocomplete="off">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 40px;"><span class="required">*</span>时长</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input vip_time" name="vip_time[{$rulekey}]" value="{$rule.vip_time}" maxlength="10" placeholder="月" autocomplete="off">
                            </div>
                        </div>
                        {if condition="($rulekey > 0)"}
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <button type="button" class="layui-btn layui-btn-danger delRule-btn"><i class="layui-icon layui-icon-delete"></i></button>
                                </div>
                            </div>
                        {/if}
                    </div>
                {/foreach}
            </div>

            <div class="layui-form-item layui-form-text">
                <div class="layui-inline">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn layui-btn-normal addRule-btn"><i class="layui-icon"></i>新增费用标准</button>
                    </div>
                </div>
            </div>
        </div>

        <input type="hidden" name="id" value="{$info.id}">

        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/js/qiniu/plupload.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniu.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniuConfig.js" type="text/javascript"></script>

<script src="__STATIC__/admin/pages/js/uploadfile.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/memberlevel.js" type="text/javascript"></script>
{/block}